/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DTO;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Luis Olave 10
 */
public class ConversionFechas {

    // CONVERTIR DE DATE A STRING
    public static String convertToString(Date date) {
        DateFormat df;
        String dateString = null;

        df = new SimpleDateFormat("dd/MM/yyyy");

        dateString = df.format(date);

        return dateString;

    }

    // CONVERTIR DE STRING A DATE
    public static Date convertToDate(String stringDate) {
        DateFormat df;
        Date date = new Date();

        df = new SimpleDateFormat("dd/MM/yyyy");
        try {
            date = df.parse(stringDate);
        } catch (ParseException ex) {
            Logger.getLogger(ConversionFechas.class.getName()).log(Level.SEVERE, null, ex);
        }

        return date;
    }

    public static Date convertToString(String text) {
        DateFormat df;
        Date date = new Date();

        df = new SimpleDateFormat("dd/MM/yyyy");
        try {
            date = df.parse(text);
        } catch (ParseException ex) {
            Logger.getLogger(ConversionFechas.class.getName()).log(Level.SEVERE, null, ex);
        }

        return date;
    }
}
